<?php
namespace Home\Controller;
use Think\Controller;
class ShowController extends Controller{
    //var $article;
    function __construct()
    {
        parent::__construct();
        $this->article = M('article');
        $this->comment = M('comment');
    }
    function index(){
        //dump($_GET);exit;

       $id = I("get.id");

        //dump($id);exit;
         $a=$this->article->find($id);
        //echo $this->article->getLastSql();
        //dump($a);exit;

        $this->assign("a",$a);
        $comments=$this->comment->where("article_id = $id")->select();
        //dump($comments);exit;
        $this->assign('comments',$comments);
        $this->article->where("id = '$id'")->setInc('view');

        $this->display();

     }

    function comment(){
        //dump($_POST);exit;

        $this->comment->create();
        $this->comment->add();
        $this->success('新增成功');
    }
}